import sys 

if (len(sys.argv)<2):
	sys.exit("Enter file name")

# read file
stripped_name = sys.argv[1].split('/')[1].split('.')[0]
filename = 'split/'+ stripped_name.upper() + '_'
r = open(sys.argv[1])
cd1w = open(filename+'cd1.csv', 'w')
cd2w = open(filename+'cd2.csv', 'w')
top4w = open(filename+'top4.csv', 'w')
pchangew = open(filename+'pchange.csv', 'w')
hsvw = open(filename+'hsv.csv', 'w')
zipw = open(filename+'zip.csv', 'w')

lines = r.readlines()

for i in range(14):
	cd1w.write('x'+str(i)+',')
cd1w.write('label\n')

for i in range(28):
	cd2w.write('x'+str(i) +',')
cd2w.write('label\n')

for i in range(2):
	top4w.write('x'+str(i)+',')
top4w.write('label\n')

for i in range(2):
	pchangew.write('x'+str(i)+',')
pchangew.write('label\n')

for i in range(34):
	hsvw.write('x'+str(i)+',')
hsvw.write('label\n')

for i in range(1):
	zipw.write('x'+str(i)+',')
zipw.write('label\n')

for i in range(len(lines)):
	line = lines[i].split(',')
	clss = line[len(line)-1]
	cd1w.write(','.join(line[0:14]) + ',' + clss)
	cd2w.write(','.join(line[14:42]) + ',' + clss)
	top4w.write(','.join(line[42:44]) + ',' + clss)
	pchangew.write(','.join(line[44:46]) + ',' + clss)
	hsvw.write(','.join(line[46:80]) + ',' + clss)
	zipw.write(','.join(line[80:81]) + ',' + clss)

